from typing import List, Optional
from uuid import UUID
from pydantic import BaseModel, Field


class MenuCreate(BaseModel):
    parent_id: Optional[UUID] = None
    name: str
    path: str
    icon: Optional[str] = None
    order_index: int = 0
    enabled: bool = True


class MenuRead(BaseModel):
    id: UUID
    parent_id: Optional[UUID] = None
    name: str
    path: str
    icon: Optional[str] = None
    order_index: int
    enabled: bool


class MenuUpdate(BaseModel):
    parent_id: Optional[UUID] = None
    name: Optional[str] = None
    path: Optional[str] = None
    icon: Optional[str] = None
    order_index: Optional[int] = None
    enabled: Optional[bool] = None


class MenuNode(BaseModel):
    id: UUID
    name: str
    path: str
    icon: Optional[str] = None
    children: List['MenuNode'] = Field(default_factory=list)

    class Config:
        arbitrary_types_allowed = True
